package com.med.meddataintegrator.doctor.service.Impl;

import com.med.meddataintegrator.common.pojo.dos.DrugsDo;
import com.med.meddataintegrator.common.pojo.dto.drugs.DrugsParam;
import com.med.meddataintegrator.common.pojo.dto.drugs.DrugsQuery;
import com.med.meddataintegrator.common.mapper.DrugsDoMapper;
import com.med.meddataintegrator.common.pojo.vo.drugs.DrugsVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.med.meddataintegrator.doctor.service.drugsService;

import java.util.List;

@Slf4j
@Service
public class drugsServiceImpl implements drugsService{
    @Autowired
    DrugsDoMapper drugsDoMapper;

    @Override
    public List<DrugsVO> selectDrugs(DrugsQuery drugsQuery) {
        log.debug("查询药品业务：{}",drugsQuery);
        List<DrugsVO> drugsVOList = drugsDoMapper.select(drugsQuery);
        return drugsVOList;
    }

    @Override
    public void updateDrugs(DrugsParam drugsParam) {
        log.debug("更新药品业务：{}",drugsParam);
        DrugsDo drugsDo = new DrugsDo();
        BeanUtils.copyProperties(drugsParam,drugsDo);
        drugsDoMapper.updateDrugs(drugsDo);
    }

    @Override
    public void delDrugs(Integer id) {
        log.debug("删除药品业务：{}",id);
        drugsDoMapper.delDrugs(Integer.valueOf(id.toString()));
    }

    @Override
    public void addDrugs(DrugsParam drugsParam) {
        log.debug("添加药品业务：{}",drugsParam);
        DrugsDo drugsDo = new DrugsDo();
        BeanUtils.copyProperties(drugsParam,drugsDo);
        drugsDoMapper.addDrugs(drugsDo);
    }

}
